package oen.game.unpack.tools.handler;

import im.oen.boot.common.utils.Checker;

import java.io.File;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Logger;

/**
 * <p>描述：文件处理器</p>
 *
 * <p>创建时间：2021-11-10 18:02</p>
 * <p>更新时间：暂无</p>
 *
 * @author Kevin.Xu
 * @version 1.0
 */
public abstract class FileHandler {

    protected Logger log = Logger.getLogger(getClass().getName());

    public abstract boolean isSupport(File file);

    public Set<File> fetchFiles(Set<File> files) throws Exception {
        Set<File> supports = new HashSet<>();
        if (Checker.isEmpty(files)) {
            return supports;
        }

        for (File file : files) {
            if (this.isSupport(file)) {
                supports.add(file);
            }
        }
        return supports;
    }

    public abstract void process(Set<File> files) throws Exception;
}
